package com.asm.DBloader;

import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class ASM_FLocationDS {
	private SQLiteDatabase dB;
	private ASM_DB dbHelper;
	Context context;
	
	
	public ASM_FLocationDS(Context context) {
		this.context = context;
		dbHelper  = new ASM_DB(context);
		
	}
	
	public void open() throws SQLException
	{
		dB = dbHelper.getWritableDatabase();
	}
	
	public int Create(ASM_FLocation det) 
	{
		
		int count =0;
		
		if(dB == null){
			open();
		}else if(!dB.isOpen()){
			open();
		}
		
		
		ContentValues values = new ContentValues();
		
		values.put(ASM_DB.asmLoc_LocCode, det.getAsmLoc_LocCode());
		values.put(ASM_DB.asmLoc_LocName, det.getAsmLoc_LocName());
		values.put(ASM_DB.asmLoc_TeleNo, det.getAsmLoc_TeleNo());
		values.put(ASM_DB.asmLoc_FaxNo, det.getAsmLoc_FaxNo());
		values.put(ASM_DB.asmLoc_EMail, det.getAsmLoc_EMail());
		
		values.put(ASM_DB.asmLoc_LoctCode, det.getAsmLoc_LoctCode());
		values.put(ASM_DB.asmLoc_RepCode, det.getAsmLoc_RepCode());
		values.put(ASM_DB.asmLoc_Contact, det.getAsmLoc_Contact());
		values.put(ASM_DB.asmLoc_Address2, det.getAsmLoc_Address2());
		values.put(ASM_DB.asmLoc_Address3, det.getAsmLoc_Address3());
		
		values.put(ASM_DB.asmLoc_Address1, det.getAsmLoc_Address1());
		values.put(ASM_DB.asmLoc_AddMach, det.getAsmLoc_AddUser());
		values.put(ASM_DB.asmLoc_AddUser, det.getAsmLoc_AddUser());
		values.put(ASM_DB.asmLoc_AddMach, det.getAsmLoc_AddMach());
	


		
		count = (int) dB.insert(ASM_DB.ASM_FLOCATION, null, values);

		dB.close();
		return count;
		
	}
}
